Skip to content

ui: fix client detail page error#27822

Draft
arunstanhc wants to merge 12 commits intoNMD-917-core-issuefrom
NMD-917-ui-not-updating-region-switch
Draft

ui: fix client detail page error#27822
arunstanhc wants to merge 12 commits intoNMD-917-core-issuefrom
NMD-917-ui-not-updating-region-switch

Conversation

@arunstanhc
Copy link
Copy Markdown
Collaborator

@arunstanhc arunstanhc commented Apr 13, 2026

Description

This PR fixes the issue when allocations view is not updated when switching region. This leads to user seeing incorrect data and further errors when they try to interact with it - for eg. trying to access a job not existing in the newly switched region.

The changes in the PR are as below:

  • The region change was not being detected correctly in the application router when comparing active region and region from query params
    • Updated region switcher to not set the active region and let it be updated by application router after comparing with query params
  • Removed global store.unloadAll which was causing rendering errors and replaced it with route.refresh to reload active route models for the selected region
  • Updated child detail routes (job and allocation) to explicitly reload related region data, avoiding reuse of stale cache after switching regions
  • Also noticed an issue in clients details page when switching regions, where repeated calls to fetch node metrics were made. Fixed it by adding necessary guards and removing stale trackers

Testing & Reproduction steps

To reproduce the issue, set up Nomad instances with two regions and deploy a job to the federated cluster.

  • Start instance for region 1
bin/nomad agent -dev -config=india-dev.hcl
  • Start instance for region 2
bin/nomad agent -dev -config=us-dev.hcl
  • Join the instances and deploy a sample job in both instances
bin/nomad server join -address=http://127.0.0.1:5646 127.0.0.1:4648
bin/nomad job run -region=india minimal-job.nomad
bin/nomad job run -region=us minimal-job.nomad
  • Launch UI and navigate to jobs view http://localhost:4646/ui/jobs/example
  • Switch between regions and observe the recent allocations data does not refresh
  • Also click on an allocation id after switching initial region to observe object not found error

To verify the fix, please make another build with the PR branch and repeat the above steps

make dev-ui

You should see updated data for relevant region without any errors

Including the files mentioned above for reference:
NMD917-test-files.zip

Links

JIRA

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad product documentation, which is stored in the
    web-unified-docs repo. Refer to the web-unified-docs contributor guide for docs guidelines.
    Please also consider whether the change requires notes within the upgrade
    guide
    . If you would like help with the docs, tag the nomad-docs team in this PR.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

@arunstanhc arunstanhc requested review from a team as code owners April 13, 2026 04:36
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app Bot commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@arunstanhc
Copy link
Copy Markdown
Collaborator Author

Moving to draft to fix failing tests

@arunstanhc arunstanhc marked this pull request as ready for review April 22, 2026 05:35
@arunstanhc arunstanhc requested a review from jrasell April 23, 2026 11:42
@tehut
Copy link
Copy Markdown
Contributor

tehut commented Apr 27, 2026

Hi @arunstanhc, would you mind pulling the node metrics changes into a follow up PR, it would make this one a bit easier to review.


// Refresh to reload with new region data
this.refresh();
}, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why schedule this to run 0 ms later instead of executing it right away or setting a timeout value?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tehut this.refresh will basically reload the route and since we are already in a route transition (in the beforeModel phase of a route change) ember would interrupt or abort the current route transition. By using a 0 value for the later method here, we are ensuring the call to refresh is only made on the next "tick" of the run loop which would be after the current transition is complete

this.system.set('activeRegion', region);
await this.get('token.fetchSelfTokenAndPolicies').perform().catch();
// Fetch token for the new region before transitioning
await this.get('token.fetchSelfTokenAndPolicies').perform(region).catch();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we shouldn't set a default or retry in the catch block now that ln 25 is setting the value instead of overwriting an existing value.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @tehut. We do set the active region in application route beforeModel, which will be triggered after this line and in case token and policies fetch fails, the last successful values will be used. Also the application router error handler will show the error if there is an error with the token

@arunstanhc arunstanhc changed the base branch from main to NMD-917-core-issue May 3, 2026 18:09
@arunstanhc arunstanhc changed the title ui: NMD-917 - UI not updating on region switch ui: fix client detail page error May 3, 2026
@arunstanhc arunstanhc marked this pull request as draft May 3, 2026 18:47
@arunstanhc
Copy link
Copy Markdown
Collaborator Author

Hi @arunstanhc, would you mind pulling the node metrics changes into a follow up PR, it would make this one a bit easier to review.

Hello @tehut Sure thing, I have now created a new PR which address the core issue of NMD-917 and the other changes will be in this PR. Weirdly I cannot replicate the issue in clients details page (for which I added the changes in node metrics) anymore so I am moving this to draft and will make it ready after more testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants